﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using EventPlanner.Validation;

namespace EventPlanner.Models
{

    public class ChangePasswordModel: EntityBase
    {
        [Required]
        [DataType(DataType.Password)]   
        [Display(ResourceType=typeof(EventPlanner.Resources.Account.ChangePassword), Name = "lbl_ContraseñaActual")]
        public string OldPassword { get; set; }

        [Required]
        [StringLength(100, ErrorMessageResourceType=typeof(EventPlanner.Resources.Account.ChangePassword),
            ErrorMessageResourceName = "lbl_ErrorContraseñaCaracteres", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(ResourceType = typeof(EventPlanner.Resources.Account.ChangePassword), Name = "lbl_NuevaContraseña")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(ResourceType = typeof(EventPlanner.Resources.Account.ChangePassword), Name = "lbl_ConfirmarNuevaContraseña")]
        [Compare("NewPassword", ErrorMessageResourceType=typeof(EventPlanner.Resources.Account.ChangePassword),
               ErrorMessageResourceName="lbl_ErrorContraseñaDistinta")]
        public string ConfirmPassword { get; set; }
    }

    public class LogOnModel :EntityBase
    {
        [Required]
        [Display(ResourceType=typeof(EventPlanner.Resources.Global.Global), Name = "lbl_NombreUsuario")]
        public string UserName { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(ResourceType = typeof(EventPlanner.Resources.Global.Global), Name = "lbl_Contraseña")]
        public string Password { get; set; }

        [Display(ResourceType=typeof(EventPlanner.Resources.Account.LogOn), Name = "lbl_Recordarme")]
        public bool RememberMe { get; set; }
    }


    public class UserViewModel
    {
        [Display(Name = "Nombre de Usuario")]
        public string UserName { get; set; }
        [Display(Name = "Correo electrónico")]
        public string Email { get; set; }
        [Display(Name = "Última vez visto")]
        public DateTime LastSeen { get; set; }
        [Display(Name = "Fecha de creación")]
        public DateTime Created { get; set; }
        [Display(Name = "Rol")]
        public string Role { get; set; }
    }


    public class RegisterModel : EntityBase
    {
        [Required]
        [Display(ResourceType=typeof(EventPlanner.Resources.Account.Register), Name = "lbl_NombreUsuario")]
        public string UserName { get; set; }

        [Required]
        [Email]
        [Display(ResourceType = typeof(EventPlanner.Resources.Global.Global), Name = "lbl_Correo")]
        public string Email { get; set; }

        [Required]
        [StringLength(100, 
            ErrorMessageResourceType = typeof (EventPlanner.Resources.Account.Register),
            ErrorMessageResourceName = "lbl_ErrorContraseñaCaracteres", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(ResourceType=typeof(EventPlanner.Resources.Account.Register), Name = "lbl_Contraseña")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(ResourceType=typeof(EventPlanner.Resources.Account.Register), Name = "lbl_ConfirmarContraseña")]
        [Compare("Password", ErrorMessageResourceType=typeof(EventPlanner.Resources.Account.Register),
            ErrorMessageResourceName="lbl_ConfraseñaNoCoincide")]
        public string ConfirmPassword { get; set; }
        
        [Required]
        [Display(ResourceType=typeof(EventPlanner.Resources.Account.Register), Name = "lbl_Rol")]
        //[RegularExpression("@Publisher")] --->Estaria bueno validar los roles con regex
        public string Role { get; set; }

        public Boolean Activa { get; set; }
    }
}
